<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common-app/taglibs.jsp"%>
<%@ taglib uri="/WEB-INF/iristaglib.tld" prefix="iris"%>
<!DOCTYPE html>
<html>
<head>
<title>项目审核</title>
<%@ include file="/common/meta.jsp"%>

<script type="text/javascript" src="${res}/js/opinion/opinion.js"></script>
<script type="text/javascript" src="${res}/js/proposal/irisPrpPrepare.js"></script> 
<script type="text/javascript" src="${res}/js/validate/irisvalidator.js"></script>

<c:set var="audit_length">600</c:set>
<c:if test="${param.subGrantCode eq '2513' or param.subGrantCode eq '2515'}">
	<c:set var="audit_length">1000</c:set>
</c:if>


<script type="text/javascript">
var prcWin = new progressWin("${res}");//初始化遮罩层
messageTip.check_nopass="提示信息";

$(document).ready(function(){
	$("#submit1").click(function(){
		var title="同意意见";
		var opn = $("#opinionContent").val();
		if(opn==null||opn==""){
			opn = $("#opinionContent").text();
		}
		if($.trim(opn).length==0){
			scmWarn("请输入"+title+"!");
			return false;
		}
		if(opn.length>500){
			scmWarn(title+"限500字内!");
			return false;
		}
		$("#status").val("04");
		var options = {
				beforeSubmit : function() {
					$("#submit1").attr("disabled",true);
					$("#submit2").attr("disabled",true);
					$("#submit3").attr("disabled",true);
					prcWin.openWin();//打开遮罩层
				}, // 表单提交前的回调函数
				success : function(msg) {
					if(msg == 'success'){
						scmSuccess("操作成功",null,2000);
						if("${param.subGrantCode}"=="0" ){
							parent.irisGrid.getGridDom().jqGrid("refresh",0);//0是本页1是首页
							parent.$("#searchBt").click();
							parent.tb_remove();
						}
						if("${param.subGrantCode}"!="0" ){
							parent.currefresh=false;
							window.parent.opener.search();
							window.parent.opener.reflushBu();
							window.close();
						}
					}else{
						scmError("操作失败！");
					}			
				},// 表单成功提交后的回调函数
				error : function() {
					scmError("操作失败,请联系系统管理员");
					prcWin.closeWin();
				},
				url: "${ctx}/appProject/batch_audit_pf"
			};
		$("#mainForm").ajaxSubmit(options);	
	});
	$("#submit2").click(function(){
		var title="不同意意见";
		var opn = $("#opinionContent").val();
		if(opn==null||opn==""){
			opn = $("#opinionContent").text();
		}
		if($.trim(opn).length==0){
			scmWarn("请输入"+title+"!");
			return false;
		}
		if(opn.length>500){
			scmWarn(title+"限500字内!");
			return false;
		}
		$("#status").val("03");
		var options = {
				beforeSubmit : function() {
					$("#submit1").attr("disabled",true);
					$("#submit2").attr("disabled",true);
					$("#submit3").attr("disabled",true);
					prcWin.openWin();//打开遮罩层
				}, // 表单提交前的回调函数
				success : function(msg) {
					if(msg == 'success'){
						scmSuccess("操作成功",null,2000);
						if("${param.subGrantCode}"=="0" ){
							parent.irisGrid.getGridDom().jqGrid("refresh",0);//0是本页1是首页
							parent.$("#searchBt").click();
							parent.tb_remove();
						}
						if("${param.subGrantCode}"!="0" ){
							window.close();
						}
					}else{
						scmError("操作失败！");
					}			
				},// 表单成功提交后的回调函数
				error : function() {
					scmError("操作失败,请联系系统管理员");
					prcWin.closeWin();
				},
				url: "${ctx}/appProject/batch_audit_pf"
			};
		$("#mainForm").ajaxSubmit(options);	
	});

	$("#submit3").click(function(){
		var title="退回修改意见";
		var opn = $("#opinionContent").val();
		if(opn==null||opn==""){
			opn = $("#opinionContent").text();
		}
		if($.trim(opn).length==0){
			scmWarn("请输入"+title+"!");
			return false;
		}
		if(opn.length>500){
			scmWarn(title+"限500字内!");
			return false;
		}
		$("#status").val("00");
		var options = {
				beforeSubmit : function() {
					$("#submit1").attr("disabled",true);
					$("#submit2").attr("disabled",true);
					$("#submit3").attr("disabled",true);
					prcWin.openWin();//打开遮罩层
				}, // 表单提交前的回调函数
				success : function(msg) {
						scmSuccess("操作成功",null,2000);
						if("${param.subGrantCode}"=="0" ){
							parent.irisGrid.getGridDom().jqGrid("refresh",0);//0是本页1是首页
							parent.$("#searchBt").click();
							parent.tb_remove();
						}
						if("${param.subGrantCode}"!="0" ){
							window.close();
						}	
				},// 表单成功提交后的回调函数
				error : function() {
					scmError("操作失败,请联系系统管理员");
					prcWin.closeWin();
				},
				url: "${ctx}/appProject/batch_audit_pf"
			};
		$("#mainForm").ajaxSubmit(options);	
	});
$("#back").click(function(){
	if("${param.subGrantCode}"=="0" ){
	parent.irisGrid.getGridDom().jqGrid("refresh",0);//0是本页1是首页
	parent.$("#searchBt").click();
	parent.tb_remove();
	}
	if("${param.subGrantCode}"!="0" ){
	window.close();
	}
});
refreshOpinins();
});

function check() {
	validate($("#confirmTable"), $("#confirmTable").attr("title"));
	
    if(!valResult()){
		irisValShowMsg($("#wbox1"));
		return false;
	}
	return true;
}



function openprpapprovedialog(flag){
	if (flag) {
		var url="${ctx}/prpapprove/openprpapprovedialog?category=${userOpinion.category}&flag="+flag+"&showGrant=true&TB_iframe=true&height=390&width=720";
		var title="";
		tb_show(title,url,false);
	}
}

function viewComment(){
	
	var url="${ctx}/proposal/view/audit-comment-view?posCode="+encodeURIComponent("${param.posCode}")+"&flag=historyOpinion&TB_iframe=true&height=390&width=720";
    var title="历史审核意见";
    tb_show(title,url,false);
}





function setChangeValue(selObj){
	if (selObj.value > 0)
		$("#opinionContent").val($(selObj).find("option:selected").attr("title"));
	else 
		$("#opinionContent").val("");
}
//刷新意见下拉列表
function refreshOpinins(){
	$.ajax({
		async:true,
		type:'post',
		data:{
			"userOpinion.grantCode":"${param.grantCode}",
			"userOpinion.category":"${userOpinion.category}",
			"flag":"ajaxOpinions"
		},
		success : function(data) {
			$("#opininsSpan").html("");
				var opinins='<select onchange="setChangeValue(this)" style="width:150px; overflow:hidden">'+
								'<option value="-1">请选择</option>';
				for (var i in data) {
					   if(data[i].content.length > 20){
					       opinins+='<option title = "'+data[i].content+'" value="'+data[i].id+'">'+data[i].content.substr(0,20)+"......"+'</option>';
					   }else{
						   opinins+='<option title = "'+data[i].content+'" value="'+data[i].id+'">'+data[i].content+'</option>';
					   }
				}
					opinins+='</select>';
				$("#opininsSpan").html(opinins);
		
		},
		error : function() {
			scmError("操作失败,请联系系统管理员");
		},
		url: "${ctx}/prpapprove/openprpapprovedialog"
	});
}


</script>
</head>
<body>
<c:if test="${param.subGrantCode ne '0' or empty param.subGrantCode}">
    <center>

        <iframe id="prpFrame"  frameborder="0"   height="500px" width="1000px" src=""></iframe>

	</center>
 </c:if> 
 <form method="post" id="mainForm">
		<input type="hidden" id="xmlData" name="xmlData">

	    <c:set var="xmlstr" value="${xmlData}" />
	    <x:parse var="xmlData" xml="${xmlstr}" />
		<input type="hidden" id="prpCodes" name="prpCodes" value="${param.prpCodes}" />
		<input type="hidden" id="type" name="type" value="${param.type}" />
		<input type="hidden" id="category" value="${userOpinion.category}"/>
		<input type="hidden" id="grant_type" name="grant_type" value="${param.grant_type}" />
		<input type="hidden" id="passFiles" name="passFiles" value="" />
		
		<input type="hidden" id="status" name="status" value="" />
	

	
		<center>
			选择常用审核意见：
			<span id="opininsSpan">
				
			</span>
			<div>
			    <button onclick="javascript:viewComment()" class="button_01">查看历史审核意见</button>
				<button onclick="saveUserOpinion('${ctx}', this, 'main-opinion')" class="button_01">添加至常用意见箱</button>
				<button onclick="openprpapprovedialog('list4opinions')" class="button_01">编辑常用意见箱</button>
			</div>
			 <table class="t_css" width="970px"  border="0" cellpadding="0" cellspacing="1" style="margin-left: 0;margin-right: 0;margin-top: 0;">
			    <tr style="margin-left: 0;margin-right: 0;margin-top: 0;">
			    <td style="color: red;margin-left: 0;margin-right: 0;margin-top: 0;" align="left">${opinion }</td>
			    </tr>
		        <tr class="li_1">
		          <td width="100%">
		          	<textarea name="opinionContent" id="opinionContent" style="width:100%;resize:none;" class="input_textarea" rows="8" maxlength="${audit_length}" onfocus="InitInput.setMaxLength(this,${audit_length})"></textarea>
	          		<input type='hidden' name='sign_org:organization/opinion_hidden' id='opinion_hidden_org' value=''>
	          		<input type='hidden' name='sign_org:recommend/opinion_hidden' id='opinion_hidden_recommend' value=''>
		          </td>
		        </tr>
	      	</table>
	      	<br/>
      	</center>
      	<br/>
      <div style="text-align: center;">
     
        <input type="button" class="button_01" value="同意" id="submit1" />
    
      	&nbsp;<input type="button" class="button_01" value="不同意" id="submit2" />
      	&nbsp;<input type="button" class="button_01" value="退回修改" id="submit3" />
    
        &nbsp;<input type="button" class="button_01" value="关闭" id="back"/>
		</div>
		</form>   
		<script type="text/javascript">
	function loadPrpView(){
		  document.getElementById("prpFrame").src = "${ctx}/proposal/view-prp?posCodeStr="+encodeURIComponent("${param.posCode}")+"&grantCodeStr=<iris:des3 code="${param.grantCode}|${curDate}" encryptKey="111111222222333333444444" />&subGrantCodeStr=<iris:des3 code="${param.subGrantCode}|${curDate}" encryptKey="111111222222333333444444" />";
	}
	
	
	
	if("${param.subGrantCode}"!="0" ){
	loadPrpView();
	}
	</script>
</body>
</html>